package com.example.service.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.example.dao.IUserDao;
import com.example.entity.Staff;
import com.example.entity.User;
import com.example.service.IUserService;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;

/**
 * Create By ChenXiAoBin
 * on 2019/4/28
 */
@Service
public class UserServiceImpl extends ServiceImpl<IUserDao, User> implements IUserService {
    @Autowired
    private IUserDao userDao;

    @Override
    public User selectId(Integer id) {
        return userDao.selectId(id);
    }

    @Override
    public void getUserInfoMap() {
//        Map map = new HashMap();
//        map.put("id", "where id = 1");
//        userDao.selectOneById(map);
        Date begTimeOne = DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -7));

        Date endTime = DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1));

        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        cal.add(6, -1);
        Date timeTwo = new DateTime(cal.getTime());

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, -1);
        Date time = calendar.getTime();
    }

    @Override
    public void getTest(String... name) {

    }

    @Override
    public void testList(List<Staff> staff) {
        //根据下标获取数组集合 .clear()清楚
        staff.subList(0,10).clear();

        //list拆分成200个一组
        List<List<Staff>> deviceVOList = Lists.partition(staff, 200);

    }

}
